package com.veo.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

@Controller
@RequestMapping("/user")
public class UserController {

    @RequestMapping("/hello")
    public ModelAndView hello(){
        ModelAndView mv = new ModelAndView();
        mv.setViewName("success");
        return mv;
    }

    @RequestMapping(value = "/requestBody",method = RequestMethod.POST)
    public String requestBody(@RequestBody(required = false) String body){
        System.out.println(body);
        return "success";
    }

    @RequestMapping("/pathVatiable/{uid}")
    public String pathVatiable(@PathVariable("uid") String uid){
        System.out.println(uid);
        return "success";
    }

    @RequestMapping("/requestHeader")
    public String requestHeader(@RequestHeader("Accept-Language") String language){
        System.out.println(language);
        return "success";
    }

    @RequestMapping("/cookieValue")
    public String cookieValue(@CookieValue(value = "JSESSIONID",required = false) String cookieValue){
        System.out.println(cookieValue);
        return "success";
    }


    @ModelAttribute
    public String  mode(String name){
        name = "张三";
        System.out.println("modeAndAttribute:"+name);
        return name;
    }

    @RequestMapping("/modeAndAttribute")
    public String modeAndAttribute(String name){
        System.out.println(name);
        return "success";
    }
}
